package SeeADoctor;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class SeeaDoctorTest {
        public static void main(String[] args) {
            Queue<Integer> patientQueue = new LinkedList<>();
            Scanner scanner = new Scanner(System.in);

            while (true) {
                System.out.println("1:排队 2:就诊 3:查看排队 4:不再排队,余下依次就诊 5:下班");
                System.out.print("请选择:");
                int choice = scanner.nextInt();

                switch (choice) {
                    case 1:
                        System.out.print(">>输入病历号:");
                        int patientId = scanner.nextInt();
                        patientQueue.add(patientId);
                        System.out.println("病历号为 " + patientId + " 的病人已加入排队。");
                        break;
                    case 2:
                        if (!patientQueue.isEmpty()) {
                            int currentPatient = patientQueue.poll();
                            System.out.println(">>病人 " + currentPatient + " 就诊");
                        } else {
                            System.out.println(">>没有病人排队");
                        }
                        break;
                    case 3:
                        if (!patientQueue.isEmpty()) {
                            System.out.print(">>排队病人: ");
                            for (int id : patientQueue) {
                                System.out.print(id + " ");
                            }
                            System.out.println();
                        } else {
                            System.out.println(">>没有病人排队");
                        }
                        break;
                    case 4:
                        if (!patientQueue.isEmpty()) {
                            System.out.print(">>病人按以下顺序就诊: ");
                            while (!patientQueue.isEmpty()) {
                                int id = patientQueue.poll();
                                System.out.print(id + " ");
                            }
                            System.out.println();
                        } else {
                            System.out.println(">>没有病人排队");
                        }
                        scanner.close();
                        return;
                    case 5:
                        if (!patientQueue.isEmpty()) {
                            System.out.println("未就诊的病人明天再来。");
                        }
                        scanner.close();
                        return;
                    default:
                        System.out.println("无效的选择，请重新输入。");
                }
            }
        }
}
